package org.wlci.captur.ui.customer;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.inject.Inject;

import org.wlci.captur.service.TestApplicationInterface;
import org.wlci.captur.service.TestServiceRemote;

@ManagedBean(name="maintainCustomer2")
@SessionScoped
public class MaintainCustomer {

	@Inject
	private TestServiceRemote service;
	
	private TestApplicationInterface ai;
	
	private List<Customer> customers = new ArrayList<Customer>();
	
	private Customer customer = new Customer();
	private Customer customerToDelete;

	@PostConstruct
	public void init() {
		ai = service.createTestApplicationInterface2();
	}
	
	public String addCustomer() {
		
		System.out.println( "Adding customer 123!" );
		
		customers.add( customer );
		customer = new Customer();
		
		return null;
	}

	public String deleteCustomer() {
		customers.remove( customerToDelete );
		return null;
	}
	
	public void setCustomerToDelete( Customer customer ) {
		customerToDelete = customer;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public List<Customer> getCustomers() {
		return customers;
	}
	
	public String sayHello() {
//		TestServiceResult result = service.testService();
		
		ai.testBeanRemotely();
		
		return null;
	}
	
}
